"use strict";function _readOnlyError(a){throw new Error("\""+a+"\" is read-only")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;dj&&(l=j/d),c*=l,d*=l,l=1,c>k&&(l=k/c),c=a(c*l),d=a(d*l)}var m=this.helper.getPageScroll(),n=m.yScroll+.5*h,o=n-.5*d,p=m.xScroll,q=document.getElementById("lightboxImage");q.style.width=c,q.style.height=d,this.resizeImageContainer(c,d,o,p)}}},{key:"resizeImageContainer",value:function resizeImageContainer(a,b,d,e){var f=Math.max,g=this,h=document.getElementById("outerImageContainer"),i=document.getElementById("imageDataContainer");if(h&&i){this.config.widthCurrent=h.offsetWidth,this.config.heightCurrent=h.offsetHeight;var j=f(350,a+2*(this.config.borderSize||0)),k=b+2*(this.config.borderSize||0);this.config.xScale=100*(j/this.config.widthCurrent),this.config.yScale=100*(k/this.config.heightCurrent),this.helper.setLightBoxPos(d,e),c("#imageDataContainer").animate({width:j},this.config.resizeSpeed,"linear"),c("#outerImageContainer").animate({width:j},this.config.resizeSpeed,"linear",function(){c("#outerImageContainer").animate({height:k},g.config.resizeSpeed,"linear",function(){g.showImage()})}),this.showNavigationElements(),document.getElementById("prevLink")&&(document.getElementById("prevLink").style.height=b),document.getElementById("nextLink")&&(document.getElementById("nextLink").style.height=b)}}},{key:"showImage",value:function showImage(){this.helper.show(document.getElementById("imageData")),this.helper.show(document.getElementById("caption")),this.helper.hide(document.getElementById("loading")),0this.config.activeImage){var c=new Image;c.src=this.config.imageArray[this.config.activeImage+1][0]}if(0"+this.config.strings.download+"":"",g="";1"+this.config.strings.prevLinkText+""),(this.config.activeImage+1"+this.config.strings.nextLinkText+"")),c=d+c+e+f+g,""!=c&&document.getElementById("numberDisplay")&&(document.getElementById("numberDisplay").innerHTML=c,this.helper.show(document.getElementById("numberDisplay")))}},{key:"showNavigationElements",value:function showNavigationElements(){var a=document.getElementById("prevLink"),b=document.getElementById("prevLinkText"),c=document.getElementById("nextLink"),d=document.getElementById("nextLinkText");1",a=1!=b.querySelectorAll("param").length),b=null}return a}},{key:"getPageScroll",value:function getPageScroll(){var a=0,b=0;self.pageYOffset?(b=self.pageYOffset,a=self.pageXOffset):document.documentElement&&document.documentElement.scrollTop?(b=document.documentElement.scrollTop,a=document.documentElement.scrollLeft):document.body&&(b=document.body.scrollTop,a=document.body.scrollLeft);var c=document.getElementById("wpadminbar");if(c){var d=window.getComputedStyle(c),e=d.getPropertyValue("top");this.config.adminBarHeight&&0===parseInt(e,10)&&(b+=this.config.adminBarHeight)}return{xScroll:a,yScroll:b}}},{key:"setLightBoxPos",value:function setLightBoxPos(a,b){return 0
",e="
";this.config.displayHelp&&(e+=""+this.config.strings.help+""),e+="
";var f;this.config.navbarOnTop?(f="
"+e+d+"
",c("body").append(f),c("#imageDataContainer").addClass("ontop")):(f="
"+d+e+"
",c("body").append(f));var g=document.getElementById("overlay"),h=document.getElementById("lightbox"),i=document.getElementById("loadingLink"),j=document.getElementById("bottomNavClose"),k=document.getElementById("outerImageContainer"),l=document.getElementById("imageDataContainer"),m=document.getElementById("lightboxImage"),n=document.getElementById("hoverNav");g&&(g.addEventListener("click",function(){return a.end()}),this.helper.hide(g)),h&&(h.addEventListener("click",function(){return a.end()}),this.helper.hide(h)),i&&i.addEventListener("click",function(){return a.end()}),j&&j.addEventListener("click",function(){return a.end()}),this.events.bindNavigationButtons(this.display.changeImage.bind(this.display)),this.events.enableKeyboardNav(this.display.changeImage.bind(this.display)),k&&(k.style.width=this.config.widthCurrent+"px",k.style.height=this.config.heightCurrent+"px"),l&&(l.style.width=this.config.widthCurrent+"px")}},{key:"resizeListener",value:function resizeListener(){var a=this;this.config.resizeTimeout&&(clearTimeout(this.config.resizeTimeout),this.config.resizeTimeout=!1),this.config.resizeTimeout=setTimeout(function(){a.display.doScale(!1)},50)}},{key:"start",value:function start(b){var d=this;document.querySelectorAll("select, embed, object").forEach(function(a){d.helper.hide(a)});var e=this.helper.getPageSize(),f=this.helper.getPageScroll(),g=0,h=document.getElementById("overlay");c("#overlay").hide().css({width:e.pageDocumentWidth+"px",height:e.pageDocumentHeight+"px",opacity:this.config.overlayOpacity}).fadeIn(400),this.config.isIE8&&4096==e.pageDocumentHeight&&1e3<=f.yScroll&&(g=f.yScroll-1e3,0>e.documentScrollHeight-(f.yScroll+3096)&&(g-=f.yScroll+3096-e.documentScrollHeight),h.style.top=g+"px");var k=0;if(!this.config.jsonData)if(this.config.imageArray=[],!b.rel||""==b.rel){var l=b.title||b.parentElement.firstChild.title||"";console.log(b),this.config.imageArray.push([b.href,this.config.displayTitle?l:""])}else document.querySelectorAll("a").forEach(function(c){if(c.href&&c.rel===b.rel){var a="",e=c.parentElement.querySelector("img:first-of-type");c.title?a=c.title:e&&(a=e.title);var f="",g="",h=c.parentElement.parentElement.querySelector(".gallery-caption"),i=c.parentElement.querySelector(".wp-caption-text");h?(f=h.textContent,g=h.innerHTML):i&&(f=i.textContent,g=i.innerHTML),a=a.trim(),g=g.trim(),a.toLowerCase()===g.toLowerCase()&&(a=g,f="");var j="";""!=a&&(j=""+a+""),""!=f&&(""!=a&&(j+="
"),j+=""+f+""),d.config.imageArray.push([c.href,d.config.displayTitle?j:""])}});if(1a;i--)this.config.imageArray[a][0]==this.config.imageArray[i][0]&&this.config.imageArray.splice(i,1);for(;this.config.imageArray[k][0]!=b.href;)k++}this.helper.setLightBoxPos(f[1],f[0]),this.display.changeImage(k)}},{key:"end",value:function end(){var a=this;document.getElementById("lightbox").remove(),c("#overlay").fadeOut(function(){document.getElementById("overlay").remove()}),document.querySelectorAll("select, embed, object").forEach(function(b){a.helper.show(b)})}}]),a}();b.exports=g},{"./Display":3,"./Events":4,"./Helper":5}]},{},[1]);